<?php
header('Content-Type:text/html; charset=UTF-8');
session_start();
if (empty($_SESSION['user'])) {
    header('location:dl.php');
    exit();
}
@$czid = $_REQUEST['czid'];
$pdo = new PDO('mysql:dbname=dcxt;charset=utf8', 'root');
if ($czid != null) {
    $s6 = $pdo->prepare('delete from cz where cz.id=:sccz');
    $s6->execute(array(
        'sccz' => $czid
    ));
}
?>
<html>
<head>
<title>Bootstrap 模板</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
	charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="web/css/bootstrap.min.css" rel="stylesheet">
<script src="web/js/jquery-1.11.1.min.js"></script>
<script src="web/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
		<script src="js/html5shiv.js"></script>
		<script src="js/respond.min.js"></script>
		<![endif]-->
</head>
<body>
	<?php include 'dh.php'; ?>
	<div class="container">
		<div class="col-xs-2">
			<a href="tjcz.php" class="btn btn-default btn-block">添加餐桌</a>
			<a href="dcxt.php" class="btn btn-default btn-block">返回首页</a>
		</div>
		<div class="col-xs-10">
			<div class="panel panel-primary">
				<div class="panel-heading">
					<div class="panel-lilte">
						<span class="glyphicon glyphicon-list">
							<b>餐桌列表</b>
						</span>
					</div>
				</div>
				<table class="table table-hover table-bordered ">
					<tr>
						<th>名称</th>
						<th></th>
					</tr>
					<?php
    $s = $pdo->prepare('select * from cz');
    $s->execute();
    $data = $s->fetchAll(PDO::FETCH_NAMED);
    foreach ($data as $value) {
        ?>			
					<tr>
						<td><?php echo $value['czm']?></td>
						<td>
							<a href="czbj.php?czid=<?php echo $value['id']?>">编辑</a>
							<a href="czlb.php?czid=<?php echo $value['id']?>"
								data-toggle="modal">删除</a>
						</td>
					</tr>
					<?php }?>			
				</table>
			</div>
		</div>
	</div>
	<div id="sccz" class="modal">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss="modal">&times;</button>
					<h3 class="modal-title">确定删除[
					<?php
    $s = $pdo->prepare('select * from cz where cz.id=:czid');
    $s->execute(array(
        'czid' => $czid
    ));
    $data = $s->fetchAll(PDO::FETCH_NAMED);
    foreach ($data as $value1) {
        echo $value1[czm];
    }
    ?>
					]</h3>
				</div>
				<div class="modal-body">你确定要删除餐桌[<?php echo $value1[czm]?>]吗？</div>
				<div class="modal-footer">
					<a href="czlb.php?czid=<?php echo $czid?>" class="btn btn-default">确定</a>
					<button class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

